<%@ page language="java" contentType="text/html; charset=UTF-8"%>
<%@include file="/include/common/gridbackhead.jsp"%>
<%!
private class PageAction extends BaseAction{
	ResultSet rs = null;
	StringBuilderEx sql = null;
	
	protected void prepareActionEnv() throws Exception{
		sql = new StringBuilderEx();
	}
	
	//加載頁面默認數據
	protected boolean onLoadDefault() throws Exception{
		//設置默認值	
		form.spsv("org", utils.getDeptName());
		form.spsv("suborg", "1");
		form.spsv("orgtsn", utils.getHr003Tsn());
		onSearchRetrieveResult();
		return true ;
	}
	// 取出查询結果
	protected void onSearchRetrieveResult() throws Exception{
		rs = utils.executeQuery("info5", onSearchGetSql());
		ret.SetSearchResult(rs);
	}
	
	//返回查詢sql語句
	protected String onSearchGetSql() throws Exception{
		sql.Reset();
		sql.Append("select top 50 b.chfullname, a.hrnum,a.chname from hr..hr005 a ,hr..hr003 b where a.fhr003tsn= b.tsn and a.leaveday = '' ");
		if(!form.isNullOrEmpty("orgtsn")){
			if("1".equals(form.gpsv("suborg"))){
				sql.Append(" and b.tsn in(%1$s)",utils.getSubHr003Tsn(form.gpsv("orgtsn"),"'",",",true));
			}else{
				sql.Append(" and b.tsn = '%1$s'",form.gpsv("orgtsn"));
			}
		}
		
		if(!form.isNullOrEmpty("hrnum")){
			sql.Append(" and a.hrnum = '%1$s'",form.gpsv("hrnum"));
		}
		sql.Append("order by b.tsn,b.srt");
		return sql.toString();
	}
}
%>
<%@include file="/include/common/gridbackend.jsp"%>